<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\common\library\Ems;
use app\common\library\Sms;
use fast\Random;
use think\Validate;

class Yzuser extends Api
{

    protected $noNeedLogin = ['*'];
    protected $noNeedRight = '*';

    public function _initialize()
    {
        parent::_initialize();
        header('Access-Control-Allow-Origin:*');
    }

    /**
     * 会员中心
     */
    public function index()
    {
        $this->view->assign('title', __('User center'));
        return $this->view->fetch();
    }

    /**
     * 会员登录接口
     */
    public function yzuser()
    {
        // if(isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && strtolower($_SERVER["HTTP_X_REQUESTED_WITH"])=="xmlhttprequest"){
            $name = input('name')?input('name'):'a';
            $pass = md5(input('password')?input('password'):666999);
            $user = $this->getUserInfo($name);
            // dump($users);exit;
            if($user && $user['Password']==$pass){
                return json(['code'=>1,'res'=>1,'msg'=>'登录成功','data'=>$user]);
            } else {
                return json(['code'=>1,'res'=>0,'msg'=>'用户名或密码错误']);
            }

    }

}
